#include "thread_object.h"

ThreadObject::ThreadObject()
{

}

ThreadObject::~ThreadObject()
{
	pthread_join(thread_id_, NULL);
}

void ThreadObject::setName(std::string x)
{
	name_ = x;
}

std::string ThreadObject::getName()
{
	return name_;
}

void ThreadObject::run()
{
	pthread_create(&thread_id_, NULL, thread, this);
}

void ThreadObject::join()
{
	pthread_join(thread_id_, NULL);
}

friend void* ThreadObject::thread(void* x)
{
	ThreadObject* thread;
	thread = static_cast<ThreadObject*>(x);
	thread->doSomething();
}